﻿// <copyright file="IDataProvider.cs" company="Signal Processing Lab, Wuhan University">
// Copyright (c) 2009-2010 All Right Reserved
// </copyright>
// <author>Xinping Deng</author>
// <email>dentoby@gmail.com</email>
// <date>2010-3</date>
// <summary>This is part of Image.NET project.</summary>

namespace SPLWHU.Core.Raster
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// The data provider interface. Reads or writes data from a file or data base.
    /// </summary>
    /// <typeparam name="T">The data type.</typeparam>
    public interface IDataProvider<T>
    {
        /// <summary>
        /// Gets the width of the image.
        /// </summary>
        /// <value>The width of the image.</value>
        int ImageWidth { get; }

        /// <summary>
        /// Gets the height of the image.
        /// </summary>
        /// <value>The height of the image.</value>
        int ImageHeight { get; }

        /// <summary>
        /// Gets or sets the specified row data.
        /// </summary>
        /// <param name="y">The row index.</param>
        /// <returns>The row data.</returns>
        T[] this[int y]
        {
            get;
            set;
        }

        /// <summary>
        /// Gets the specified column data.
        /// </summary>
        /// <param name="x">The column index.</param>
        /// <returns>The column data.</returns>
        T[] GetColumn(int x);

        /// <summary>
        /// Sets the specifed column data.
        /// </summary>
        /// <param name="x">The column index.</param>
        /// <param name="data">The column data.</param>
        void SetColumn(int x, T[] data);

        /// <summary>
        /// Gets the data in the specified region.
        /// </summary>
        /// <param name="x">The starting column index.</param>
        /// <param name="y">The starting row index.</param>
        /// <param name="height">The height of the region.</param>
        /// <param name="width">The width of the region.</param>
        /// <returns>The data in the region.</returns>
        Matrix<T> GetData(int x, int y, int height, int width);

        /// <summary>
        /// Sets the data in the specified region.
        /// </summary>
        /// <param name="x">The starting column index.</param>
        /// <param name="y">The starting row index.</param>
        /// <param name="data">The data to be filled.</param>
        void SetData(int x, int y, Matrix<T> data);

        /// <summary>
        /// Gets the data in the specifed region (interpolating).
        /// </summary>
        /// <param name="x">The starting column index.</param>
        /// <param name="y">The starting row index.</param>
        /// <param name="height">The height of the original region.</param>
        /// <param name="width">The width of the original region.</param>
        /// <param name="dstHeight">Height of the destination region.</param>
        /// <param name="dstWidth">Width of the destination region.</param>
        /// <returns>The interpolating data.</returns>
        Matrix<T> GetData(int x, int y, int height, int width, int dstHeight, int dstWidth);

        /// <summary>
        /// Sets the data to the specifed region (interpolating).
        /// </summary>
        /// <param name="x">The starting column index.</param>
        /// <param name="y">The starting row index.</param>
        /// <param name="dstHeight">Height of the destination region.</param>
        /// <param name="dstWidth">Width of the destination region.</param>
        /// <param name="data">The data to be filled.</param>
        void SetData(int x, int y, int dstHeight, int dstWidth, Matrix<T> data);
    }
}
